home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Visual Basic Source Code
/
Visual Basic Source Code.iso
/
vbsource
/
aandbf1g
/
form1.frm
< prev
next >
Wrap
Text File
|
1999-08-22
|
10KB
|
365 lines
VERSION 5.00
Begin VB.Form Form1
BorderStyle = 1 'Fixed Single
Caption = "Generic Multiple CD Player"
ClientHeight = 1905
ClientLeft = 45
ClientTop = 330
ClientWidth = 7065
Icon = "Form1.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 1905
ScaleWidth = 7065
StartUpPosition = 2 'CenterScreen
Begin VB.Timer Timer1
Interval = 1000
Left = 4200
Top = 960
End
Begin VB.CommandButton Command8
Caption = "About..."
Height = 255
Left = 120
TabIndex = 11
Top = 120
Width = 1215
End
Begin VB.PictureBox Picture1
BackColor = &H00004040&
Height = 735
Left = 2520
ScaleHeight = 675
ScaleWidth = 4395
TabIndex = 9
Top = 120
Width = 4455
Begin VB.Image Image1
Height = 330
Left = 0
Picture = "Form1.frx":08CA
Top = 0
Width = 2340
End
Begin VB.Label Label3
Alignment = 1 'Right Justify
BackStyle = 0 'Transparent
BeginProperty Font
Name = "Arial"
Size = 15.75
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000C0C0&
Height = 495
Left = 1680
TabIndex = 12
Top = 120
Width = 2535
End
Begin VB.Label Label2
BackColor = &H00008080&
BackStyle = 0 'Transparent
Caption = "Current CD Drive"
ForeColor = &H0000C0C0&
Height = 255
Left = 120
TabIndex = 10
Top = 360
Width = 3135
End
End
Begin VB.CommandButton Command7
Caption = "Close"
Height = 495
Left = 6120
TabIndex = 7
Top = 1320
Width = 855
End
Begin VB.CommandButton Command6
Caption = "Eject"
Height = 495
Left = 5280
TabIndex = 6
Top = 1320
Width = 855
End
Begin VB.CommandButton CD
Height = 255
Index = 0
Left = 120
TabIndex = 5
Top = 960
Visible = 0 'False
Width = 735
End
Begin VB.CommandButton Command5
Caption = "Stop"
Height = 495
Left = 3960
TabIndex = 4
Top = 1320
Width = 1095
End
Begin VB.CommandButton Command4
Caption = "Pause"
Height = 495
Left = 3000
TabIndex = 3
Top = 1320
Width = 975
End
Begin VB.CommandButton Command3
Caption = "Track>>"
Height = 495
Left = 2040
TabIndex = 2
Top = 1320
Width = 975
End
Begin VB.CommandButton Command2
Caption = "Play"
Height = 495
Left = 1080
TabIndex = 1
Top = 1320
Width = 975
End
Begin VB.CommandButton Command1
Caption = "<<Track"
Height = 495
Left = 120
TabIndex = 0
Top = 1320
Width = 975
End
Begin VB.Label Label1
Caption = "Available Audio CD Drives"
Height = 255
Left = 120
TabIndex = 8
Top = 720
Width = 2055
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim CurrentCd As String
Dim mssg As String * 255
Public Sub Detect_CDs()
Dim SmallString As String
Dim NextDrive As String
Static z As Integer
alldrives$ = Space$(64)
'Get all drives on your PC as one long string
ret& = GetLogicalDriveStrings(Len(alldrives$), alldrives$)
'trim off any trailing spaces. AllDrives$
'now contains all the drive letters.
alldrives$ = Left$(alldrives$, ret&)
' "AllDrives$" contains a string of all of your drives
'in your computer, but there is a character "chr$(0)"
'between each drive letter that we must filter out.
'We will use the "FOR NEXT" function to do this.
For k = 1 To Len(alldrives$)
SmallString = Mid$(alldrives$, k, 1) 'Get one character at a time
If SmallString = Chr$(0) Then
SmallString = "" 'remove unwanted character
DriveType& = GetDriveType(NextDrive) 'Check if it is a CD drive
If DriveType = 5 Then
If CD(0).Caption = "" Then 'Our first button needs to be updated before the others.
CD(0).Caption = UCase$(NextDrive)
CD(z).Visible = True
CurrentCd = UCase$(NextDrive)
Else
'Since this is a CD drive, make a button for it.
'This code below creates command buttons
z = z + 1
Load CD(z)
CD(z).Caption = UCase$(NextDrive)
CD(z).Left = (CD(z - 1).Left) + (CD(z - 1).Width)
CD(z).Visible = True
End If
End If
NextDrive = "" 'Now that a drive was detected, clear the
'string for new info
End If
NextDrive = NextDrive & SmallString
Next k
If CD(0).Caption = "" Then
MsgBox "No Audio CDs were detected", vbInformation, ""
End
Else
UpDate_Cds
End If
End Sub
Private Sub CD_Click(Index As Integer)
i = mciSendString("stop cd", 0&, 0, 0)
i = mciSendString("close cd", 0&, 0, 0)
CurrentCd = CD(Index).Caption
UpDate_Cds
End Sub
Private Sub Command1_Click()
Dim numTracks As Integer
Dim CurTrack As Integer
'Get the current track
rc = mciSendString("status cd current track", mssg, 255, 0)
CurTrack = Str(mssg)
'Get total number of tracks
rc = mciSendString("status cd number of tracks wait", mssg, 255, 0)
numTracks = Str(mssg)
'Check to see if CD is playing
rc = mciSendString("status cd mode", mssg, 255, 0)
If Left$(mssg, 7) = "playing" Then
If CurTrack = 1 Then
rc = mciSendString("play cd from " & numTracks, mssg, 255, 0)
Else
rc = mciSendString("play cd from " & CurTrack - 1, mssg, 255, 0)
End If
Else
If CurTrack = 1 Then
rc = mciSendString("seek cd to " & numTracks, mssg, 255, 0)
Else
rc = mciSendString("seek cd to " & CurTrack - 1, mssg, 255, 0)
End If
End If
End Sub
Private Sub Command2_Click()
i = mciSendString("play cd", 0&, 0, 0)
End Sub
Private Sub Command3_Click()
Dim mssg As String * 255
Dim numTracks As Integer
Dim CurTrack As Integer
'Get the current track
rc = mciSendString("status cd current track", mssg, 255, 0)
CurTrack = Str(mssg)
'Get total number of tracks
rc = mciSendString("status cd number of tracks wait", mssg, 255, 0)
numTracks = Str(mssg)
'Check to see if CD is playing
rc = mciSendString("status cd mode", mssg, 255, 0)
If Left$(mssg, 7) =